package map.android.baidu.carpool.reservation;

import java.util.ArrayList;

import android.content.Context;
import map.android.baidu.carpool.model.AirportTransCity.Terminal;
import map.android.baidu.carpool.widget.wheel.AbstractWheelTextAdapter;

/**
 * Adapter class for old wheel adapter (deprecated WheelAdapter class).
 */
public class TerminalWheelAdapter extends AbstractWheelTextAdapter {

    private ArrayList<Terminal> mAllTerminalList;

    public void setData(ArrayList<Terminal> mAllTerminalList) {
        this.mAllTerminalList = mAllTerminalList;
    }

    public TerminalWheelAdapter(Context context) {
        super(context);
    }

    public Terminal getItem(int index) {
        return mAllTerminalList == null ? null : mAllTerminalList.get(index);
    }

    @Override
    public CharSequence getItemText(int index) {
        Terminal terminal = (Terminal) getItem(index);
        String terminalName = "";
        if (terminal == null) {
            return "";
        } else {
            terminalName = terminal.airport_name;
        }
        return terminalName;
    }

    @Override
    public int getItemsCount() {
        if (mAllTerminalList == null) {
            return 0;
        }
        return mAllTerminalList.size();
    }

}
